package com.example.plan.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.plan.common.result.Result;
import com.example.plan.model.dto.drone.DroneDTO;
import com.example.plan.model.dto.drone.DronePageDTO;
import com.example.plan.model.dto.riskAlert.RiskAlertDTO;
import com.example.plan.model.dto.riskAlert.RiskAlertPageDTO;
import com.example.plan.model.entity.RiskAlert;
import com.example.plan.model.vo.DroneVO;
import com.example.plan.model.vo.RiskAlertVO;
import com.example.plan.service.DroneService;
import com.example.plan.service.RiskAlertService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

@Data
@Slf4j
@Api(tags = "运输风险预警模块")
@RestController
@RequestMapping("riskAlert")
public class RiskAlertController {
    private final RiskAlertService riskAlertService;

    @ApiOperation(value = "新增运输风险预警")
    @PostMapping("/saveRiskAlert")
    public Result<Void> saveRiskAlert(@RequestBody @Validated RiskAlertDTO dto) {
        return riskAlertService.saveRiskAlert(dto);
    }
    @ApiOperation(value = "删除运输风险预警")
    @GetMapping("/deleteRiskAlert/{alertId}")
    public Result<Void> deleteRiskAlert(@PathVariable @NotNull Long alertId) {
        return riskAlertService.deleteRiskAlert(alertId);
    }
    @ApiOperation(value = "查询运输风险预警详情")
    @GetMapping("/getRiskAlert/{alertId}")
    public Result<RiskAlertVO> getRiskAlert(@PathVariable @NotNull Long alertId) {
        return riskAlertService.getRiskAlert(alertId);
    }
    @ApiOperation(value = "分页带条件查询运输风险预警")
    @PostMapping("/pageRiskAlert")
    public Result<IPage<RiskAlertVO>> pageRiskAlert(@RequestBody @Validated RiskAlertPageDTO dto) {
        return riskAlertService.pageRiskAlert(dto);
    }

    @ApiOperation(value = "修改运输风险预警")
    @PostMapping("/updateRiskAlert")
    public Result<Void> updateRiskAlert(@RequestBody @Validated RiskAlertDTO dto) {
        return riskAlertService.updateRiskAlert(dto);
    }
}
